package dtaskboard.client.util;

import java.util.EnumSet;
import java.util.Set;

import com.google.gwt.user.client.ui.ListBox;

public final class ListUtil {
  public static String getValue(ListBox list) {
    int index = list.getSelectedIndex();
    return list.getValue(index);
  }

  public static <T extends Enum<T>> void populate(ListBox list, Class<T> clazz) {
    Set<T> set = EnumSet.allOf(clazz);
    for (T t : set) {
      list.addItem(t.name(), t.name());
    }
  }

}
